﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyThuVien.DTO;
using System.Data;

namespace QuanLyThuVien.DAO
{
    class ChiTietPhieuTraDAO
    {
        public static void ChiTietTra(ChiTietPhieuTraDTO x)
        {
            NorthwindDataContext QLTV = new NorthwindDataContext();
            ChiTietPhieuTra c = new ChiTietPhieuTra();
            c.MaChiTietPhieuMuon = x.MaChiTietPhieuMuon1;
            c.MaPhieuTra = x.MaPhieuTra1;
            QLTV.ChiTietPhieuTras.InsertOnSubmit(c);
            QLTV.SubmitChanges();
        }
        public static DataTable layCTPM()
        {
            NorthwindDataContext cnn = new NorthwindDataContext();
            var sql = from pt in cnn.ChiTietPhieuTras
                      select new { pt.MaChiTietPhieuMuon };
            DataTable dt = new DataTable();
            dt.Columns.Add("MaCTPM",typeof(int));
            foreach (var gan in sql)
            {
                dt.Rows.Add(gan.MaChiTietPhieuMuon);
            }
            return dt;
        }

    }
}
